<?php

use Illuminate\Http\Request;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/

//Route::middleware('auth:api')->get('/user', function (Request $request) {
//    return $request->user();
//});


use Illuminate\Support\Facades\Route;

$api = app('Dingo\Api\Routing\Router');
$func = function ($api) {

    $api->group(['namespace' => 'App\Api\V2\Controller\Embed', 'prefix' => 'v2/Embed'], function ($api) {
        //开户流程
        $api->group(["prefix" => "Gtxy"], function ($api) {
            $api->post("embedPay", "GtxyController@embedPay");
            $api->post("embedQuery", "GtxyController@embedQuery");
        });

        $api->group(["prefix" => "Leshua"], function ($api) {
            $api->post("embedPay", "LeshuaController@embedPay");
        });

        $api->post("embedPay", "EmbedController@embedPay");

    });


    $api->group(["namespace" => "App\Api\V2\Controller\Vbill", "prefix" => "v2/Vbill", "middleware" => "user.api"], function ($api) {
        $api->group(["namespace" => "Alipay", "prefix" => "Alipay"], function ($api) {
            $api->group(["prefix" => "Authentication"], function ($api) {
                $api->post('certification', 'AuthenticationController@certification');
                $api->get('queryApplyInfo', 'AuthenticationController@queryApplyInfo');
                $api->post('backApplyBill', 'AuthenticationController@backApplyBill');
            });
        });

        $api->group(["prefix" => "Authentication"], function ($api) {
            $api->post('certification', 'AuthenticationController@certification');
            $api->get('queryApplyInfo', 'AuthenticationController@queryApplyInfo');
            $api->post('backApplyBill', 'AuthenticationController@backApplyBill');
        });

    });

    $api->group(['namespace' => 'App\Api\V2\Controller\Merchant', 'prefix' => 'v2/Merchant'], function ($api) {
        //开户流程
        $api->group(["prefix" => "Balance", 'middleware' => 'user.api'], function ($api) {
            $api->get("queryLimit", "BalanceController@queryLimit");
        });
        $api->group(["prefix" => "Quota", 'middleware' => 'user.api'], function ($api) {
            $api->get("getQuota", "QuotaController@getQuota");
        });

        $api->group(["prefix" => "Goods", 'middleware' => 'merchant.api'], function ($api) {
            $api->get("goodsList", "GoodsController@goodsList");
            $api->get("goodsDetails", "GoodsController@goodsDetails");
            $api->get("cateList", "GoodsController@cateList");

            $api->get("editGoods", "GoodsController@editGoods");
            $api->post("goodsDiff", "GoodsController@goodsDiff");
            $api->post("goodsSync", "GoodsController@goodsSync");
            $api->post("editGoodsPrice", "GoodsController@editGoodsPrice");
        });

    });

    //
    $api->group(["namespace" => "App\Api\V2\Controller\Store", "prefix" => "v2/Store", "middleware" => "user.api"], function ($api) {
        $api->group(["prefix" => "Quota"], function ($api) {
            $api->get("getQuota", "QuotaController@getQuota");

            $api->post("setQuota", "QuotaController@setQuota");

            $api->get("quotaBank", "QuotaController@quotaBank");
        });
    });

    //设备
    $api->group(['namespace' => 'App\Api\V2\Controller\Device', 'prefix' => 'v2/Device', 'middleware' => 'user.api'], function ($api) {

        //开户流程
        $api->group(["prefix" => "Device"], function ($api) {
            $api->get("type", "DeviceController@type");
            $api->get("listsDevice", "DeviceController@listsDevice");
            $api->post("listsDeviceExport", "DeviceController@listsDeviceExport");
        });

    });
    //v2版本
    $api->group(["namespace" => "App\Api\V2\Controller\User", "prefix" => "v2/user/User", "middleware" => "user.api"], function ($api) {
        $api->any('user_ways_all', 'UserController@user_ways_all');
        $api->any("edit_user_rate", "UserController@edit_user_rate");
        $api->any('user_ways_default', 'UserController@user_ways_default');
        $api->any('edit_user_store_all_rate', 'UserController@edit_user_store_all_rate');
        $api->any("userList", "UserController@userList");
    });

    $api->group(["namespace" => "App\Api\V2\Controller\Glow", "prefix" => "v2/glow/Index", "middleware" => "public.api"], function ($api) {
        $api->any('configure_channel', 'IndexController@configure_channel');
        $api->any('agent_level', 'IndexController@agent_level');
    });

    $api->group(["namespace" => "App\Api\V2\Controller\User", "prefix" => "v2/user/Store", "middleware" => "user.api"], function ($api) {
        $api->any('pay_ways_all', 'StoreController@pay_ways_all');
        $api->any('edit_store_rate_pc', 'StoreController@edit_store_rate_pc');

        $api->any('getUserRateList', 'StoreController@getUserRateList');

    });


    //需要token
    $api->group(['namespace' => 'App\Api\V2\Controller\Incoming', 'prefix' => 'v2/incoming/Qr', 'middleware' => 'user.api'], function ($api) {

        $api->post("createQr", "QrController@createQr");

        $api->get("listQr", "QrController@listQr");

    });

    //后台管理推广人员
    $api->group(['namespace' => 'App\Api\V2\Controller\Incoming', 'prefix' => 'v2/incoming/Worker', 'middleware' => 'user.api'], function ($api) {
        $api->post("add", "ExtensionWorkerController@add");

        $api->put("update", "ExtensionWorkerController@update");

        $api->put("status", "ExtensionWorkerController@status");

        $api->get("lists", "ExtensionWorkerController@lists");

        $api->get("select", "ExtensionWorkerController@select");

        $api->post("bind", "ExtensionWorkerController@bind");
        $api->post("three_code", "ExtensionWorkerController@threeCode");

    });

    //登录
    $api->group(['namespace' => 'App\Api\V2\Controller\Incoming', 'prefix' => 'v2/incoming/Auth'], function ($api) {
        $api->post("sms", "AuthController@sms");
        $api->post("login", "AuthController@login");
    });

    $api->group(['namespace' => 'App\Api\V2\Controller\Incoming', 'prefix' => 'v2/incoming/Worker'], function ($api) {
        $api->post("sms", "WorkerController@sms");
        $api->post("login", "WorkerController@login");
    });

    //进件
    $api->group(['namespace' => 'App\Api\V2\Controller\Incoming', 'prefix' => 'v2/incoming/Incoming', 'middleware' => 'worker.api'], function ($api) {

        //二维码是否被使用
        $api->get("storeStatus", "IncomingController@storeStatus");

        //入驻
        $api->post("incoming", "IncomingController@incoming");

        //进件查询
        $api->post("searchIncomingResults", "IncomingController@searchIncomingResults");

        //店铺信息查询
        $api->post("storeInfo", "IncomingController@storeInfo");


        $api->post("stores", "ExtensionWorkerController@stores");
        $api->post("goods", "ExtensionWorkerController@goods");
        $api->post("total", "ExtensionWorkerController@total");
        $api->post("edit", "ExtensionWorkerController@edit");
        $api->post("three_code", "ExtensionWorkerController@threeCode");

    });

    $api->group(['namespace' => 'App\Api\V2\Controller\Incoming', 'prefix' => 'v2/incoming/Upload', 'middleware' => 'worker.api'], function ($api) {
        //上传需要识别码
        $api->post("upload", "UploadController@upload");

        $api->get("getThreeQrCode", "UploadController@getThreeQrCode");

        $api->post("uploadThreeQrCode", "UploadController@uploadThreeQrCode");

    });

    $api->group(['namespace' => 'App\Api\V2\Controller\Incoming', 'prefix' => 'v2/incoming/Upload', 'middleware' => 'user.api'], function ($api) {
        //上传需要识别码
        $api->get("getThreeQrCodePc", "UploadController@getThreeQrCode");
        $api->post("uploadThreeQrCodePc", "UploadController@uploadThreeQrCode");
    });

    $api->group(['namespace' => 'App\Api\V2\Controller\Incoming', 'prefix' => 'v2/incoming/Common'], function ($api) {

        $api->get("city", "CommonController@city");


        $api->get("store_type", "CommonController@store_type");

        $api->get("vbill_store_category", "CommonController@vbill_store_category");

        $api->get("bank", "CommonController@bank");

        $api->get("sub_bank", "CommonController@sub_bank");

        $api->get("doc", "CommonController@doc");

    });

    $api->group(['namespace' => 'App\Api\V2\Controller\Mechanism', "prefix" => "v2/Mechanism"], function ($api) {
        //代理商
        $api->group(["prefix" => "Merchant", 'middleware' => 'user.api'], function ($api) {
            $api->get("get", "MerchantController@get");
        });
    });

    /**
     * 乐刷实名认证二维码
     */
    $api->group(['namespace' => 'App\Api\V2\Controller\BaseQuery', 'prefix' => 'v2/base/query', 'middleware' => 'user.api'], function ($api) {
        //获取实名认证二维码
        $api->post("getQrcodeImg", "QueryController@getQrcodeImg");
    });
    /**
     * 系统刷数据
     */
    $api->group(['namespace' => 'App\Api\V2\Controller\System', 'prefix' => 'v2/system/data', 'middleware' => 'user.api'], function ($api) {
        // 转移代理商刷数据接口
        $api->post("dataSave", "SystemDataSaveController@dataSave");
    });
};

$api->version("v1", $func);









/*   Route::group(["prefix" => "v2"], function () {

       Route::group(["prefix" => "incoming"], function () {
           Route::group(["prefix" => "Qr", "middleware" => \App\Http\Middleware\AuthenticateApi::class], function () {
               Route::post("createQr", "\App\Api\V2\Controller\Incoming\QrController@createQr");

               Route::get("lists", "\App\Api\V2\Controller\Incoming\QrController@lists");
           });

       });
   });*/

